<template>
  <a-card :bordered="false">
    <!-- 查询区域 -->
    <div class="table-page-search-wrapper">
      <a-form layout="inline" @keyup.enter.native="searchQuery">
        <a-row :gutter="24">
        </a-row>
      </a-form>
    </div>
    <!-- 查询区域-END -->

    <!-- 操作按钮区域 -->
    <div class="table-operator">
      <a-button @click="handleAdd" type="primary" icon="plus">新增</a-button>
      <a-button type="primary" icon="download" @click="handleExportXls('模板表')">导出</a-button>
      <a-upload name="file" :showUploadList="false" :multiple="false" :headers="tokenHeader" :action="importExcelUrl" @change="handleImportExcel">
        <a-button type="primary" icon="import">导入</a-button>
      </a-upload>
      <!-- 高级查询区域 -->
      <j-super-query :fieldList="superFieldList" ref="superQueryModal" @handleSuperQuery="handleSuperQuery"></j-super-query>
      <a-dropdown v-if="selectedRowKeys.length > 0">
        <a-menu slot="overlay">
          <a-menu-item key="1" @click="batchDel"><a-icon type="delete"/>删除</a-menu-item>
        </a-menu>
        <a-button style="margin-left: 8px"> 批量操作 <a-icon type="down" /></a-button>
      </a-dropdown>
    </div>

    <!-- table区域-begin -->
    <div>
      <div class="ant-alert ant-alert-info" style="margin-bottom: 16px;">
        <i class="anticon anticon-info-circle ant-alert-icon"></i> 已选择 <a style="font-weight: 600">{{ selectedRowKeys.length }}</a>项
        <a style="margin-left: 24px" @click="onClearSelected">清空</a>
      </div>

      <a-table
        ref="table"
        size="middle"
        :scroll="{x:true}"
        bordered
        rowKey="id"
        :columns="columns"
        :dataSource="dataSource"
        :pagination="ipagination"
        :loading="loading"
        :rowSelection="{selectedRowKeys: selectedRowKeys, onChange: onSelectChange}"
        class="j-table-force-nowrap"
        @change="handleTableChange">

        <template slot="htmlSlot" slot-scope="text">
          <div v-html="text"></div>
        </template>
        <template slot="imgSlot" slot-scope="text">
          <span v-if="!text" style="font-size: 12px;font-style: italic;">无图片</span>
          <img v-else :src="getImgView(text)" height="25px" alt="" style="max-width:80px;font-size: 12px;font-style: italic;"/>
        </template>
        <template slot="fileSlot" slot-scope="text">
          <span v-if="!text" style="font-size: 12px;font-style: italic;">无文件</span>
          <a-button
            v-else
            :ghost="true"
            type="primary"
            icon="download"
            size="small"
            @click="downloadFile(text)">
            下载
          </a-button>
        </template>

        <span slot="action" slot-scope="text, record">
          <a @click="handleEdit(record)">编辑</a>

          <a-divider type="vertical" />
          <a-dropdown>
            <a class="ant-dropdown-link">更多 <a-icon type="down" /></a>
            <a-menu slot="overlay">
              <a-menu-item>
                <a @click="handleDetail(record)">详情</a>
              </a-menu-item>
              <a-menu-item>
                <a-popconfirm title="确定删除吗?" @confirm="() => handleDelete(record.id)">
                  <a>删除</a>
                </a-popconfirm>
              </a-menu-item>
            </a-menu>
          </a-dropdown>
        </span>

      </a-table>
    </div>

    <matrevbase-modal ref="modalForm" @ok="modalFormOk"></matrevbase-modal>
  </a-card>
</template>

<script>

  import '@/assets/less/TableExpand.less'
  import { mixinDevice } from '@/utils/mixin'
  import { JeecgListMixin } from '@/mixins/JeecgListMixin'
  import MatrevbaseModal from './modules/MatrevbaseModal'

  export default {
    name: 'MatrevbaseList',
    mixins:[JeecgListMixin, mixinDevice],
    components: {
      MatrevbaseModal
    },
    data () {
      return {
        description: '模板表管理页面',
        // 表头
        columns: [
          {
            title: '#',
            dataIndex: '',
            key:'rowIndex',
            width:60,
            align:"center",
            customRender:function (t,r,index) {
              return parseInt(index)+1;
            }
          },
          {
            title:'报送码',
            align:"center",
            dataIndex: 'ztsendno'
          },
          {
            title:'中文名称',
            align:"center",
            dataIndex: 'ztcnname'
          },
          {
            title:'INCI名称',
            align:"center",
            dataIndex: 'ztenname'
          },
          {
            title:'状态',
            align:"center",
            dataIndex: 'ztstatus'
          },
          {
            title:'生产代码',
            align:"center",
            dataIndex: 'ztprodcode'
          },
          {
            title:'使用目的',
            align:"center",
            dataIndex: 'zttarget'
          },
          {
            title:'等同原料',
            align:"center",
            dataIndex: 'ztequalmat'
          },
          {
            title:'外观性状',
            align:"center",
            dataIndex: 'ztappearance'
          },
          {
            title:'生产商*',
            align:"center",
            dataIndex: 'ztbrand'
          },
          {
            title:'供应商',
            align:"center",
            dataIndex: 'ztsupplier'
          },
          {
            title:'所属工厂',
            align:"center",
            dataIndex: 'ztfactory'
          },
          {
            title:'产地',
            align:"center",
            dataIndex: 'ztorigin'
          },
          {
            title:'价格（元/kg)',
            align:"center",
            dataIndex: 'ztprice'
          },
          {
            title:'通用性',
            align:"center",
            dataIndex: 'ztcommon'
          },
          {
            title:'备注（通用性）',
            align:"center",
            dataIndex: 'ztcommonrem'
          },
          {
            title:'包装材质',
            align:"center",
            dataIndex: 'ztpackmat'
          },
          {
            title:'最小包装（kg)',
            align:"center",
            dataIndex: 'ztpackmin'
          },
          {
            title:'最小起订量（kg)',
            align:"center",
            dataIndex: 'ztordermin'
          },
          {
            title:'供货周期（天）',
            align:"center",
            dataIndex: 'ztsupplycycle'
          },
          {
            title:'其他',
            align:"center",
            dataIndex: 'ztother'
          },
          {
            title:'稳定性等级',
            align:"center",
            dataIndex: 'ztstability'
          },
          {
            title:'微生物敏感等级',
            align:"center",
            dataIndex: 'ztsensible'
          },
          {
            title:'保质期',
            align:"center",
            dataIndex: 'ztquqntity'
          },
          {
            title:'储存条件',
            align:"center",
            dataIndex: 'ztstore'
          },
          {
            title:'开封后储存条件',
            align:"center",
            dataIndex: 'ztopenstore'
          },
          {
            title:'注意事项',
            align:"center",
            dataIndex: 'ztcaution'
          },
          {
            title:'使用要求',
            align:"center",
            dataIndex: 'ztuserequire'
          },
          {
            title:'急性毒性',
            align:"center",
            dataIndex: 'ztviru'
          },
          {
            title:'刺激性/腐蚀性',
            align:"center",
            dataIndex: 'ztcj'
          },
          {
            title:'致敏性',
            align:"center",
            dataIndex: 'ztzm'
          },
          {
            title:'光毒性',
            align:"center",
            dataIndex: 'ztgt'
          },
          {
            title:'光变态反应',
            align:"center",
            dataIndex: 'ztgbt'
          },
          {
            title:'致突变性/遗传毒性',
            align:"center",
            dataIndex: 'ztycdx'
          },
          {
            title:'重复剂量毒性',
            align:"center",
            dataIndex: 'ztcfjldx'
          },
          {
            title:'生殖发育毒性',
            align:"center",
            dataIndex: 'ztszfytx'
          },
          {
            title:'慢性毒性/致癌性',
            align:"center",
            dataIndex: 'ztmxdx'
          },
          {
            title:'毒代动力学',
            align:"center",
            dataIndex: 'ztdddlx'
          },
          {
            title:'人体试验',
            align:"center",
            dataIndex: 'ztrtsy'
          },
          {
            title:'其他',
            align:"center",
            dataIndex: 'ztothers'
          },
          {
            title:'适用范围',
            align:"center",
            dataIndex: 'ztgxuserange'
          },
          {
            title:'使用限制',
            align:"center",
            dataIndex: 'ztgxuselimit'
          },
          {
            title:'推荐用量',
            align:"center",
            dataIndex: 'ztjsreyl'
          },
          {
            title:'原料类别',
            align:"center",
            dataIndex: 'ztxjmatclass'
          },
          {
            title:'香精级别',
            align:"center",
            dataIndex: 'ztxjclass'
          },
          {
            title:'气味',
            align:"center",
            dataIndex: 'ztxjsmell'
          },
          {
            title:'提取工艺',
            align:"center",
            dataIndex: 'ztxjprocess'
          },
          {
            title:'灵感来源',
            align:"center",
            dataIndex: 'ztxjinspire'
          },
          {
            title:'香精科技',
            align:"center",
            dataIndex: 'ztxjscience'
          },
          {
            title:'应用类别',
            align:"center",
            dataIndex: 'ztxjapptype'
          },
          {
            title:'稳定性',
            align:"center",
            dataIndex: 'ztxjstable'
          },
          {
            title:'天然成分（%）',
            align:"center",
            dataIndex: 'ztxjcomponent'
          },
          {
            title:'主成分',
            align:"center",
            dataIndex: 'ztxjmaincf'
          },
          {
            title:'香气描述',
            align:"center",
            dataIndex: 'ztxjdesc'
          },
          {
            title:'消费者描述',
            align:"center",
            dataIndex: 'ztxjzfzdesc'
          },
          {
            title:'适用性别',
            align:"center",
            dataIndex: 'ztxjsytype'
          },
          {
            title:'功效',
            align:"center",
            dataIndex: 'ztxjgx'
          },
          {
            title:'数据来源',
            align:"center",
            dataIndex: 'ztxjsjly'
          },
          {
            title:'功效数据',
            align:"center",
            dataIndex: 'ztxjgxdata'
          },
          {
            title:'权威认证',
            align:"center",
            dataIndex: 'ztxjqwrz'
          },
          {
            title:'IFRA版本',
            align:"center",
            dataIndex: 'ztifra'
          },
          {
            title:'功效',
            align:"center",
            dataIndex: 'ztgxeffect'
          },
          {
            title:'数据来源',
            align:"center",
            dataIndex: 'ztgxdatasource'
          },
          {
            title:'测试浓度',
            align:"center",
            dataIndex: 'ztgxtestthick'
          },
          {
            title:'测试结果',
            align:"center",
            dataIndex: 'ztgxtestresult'
          },
          {
            title:'其他',
            align:"center",
            dataIndex: 'ztgxother'
          },
          {
            title:'生物学靶点',
            align:"center",
            dataIndex: 'ztgxbiological'
          },
          {
            title:'科技背书',
            align:"center",
            dataIndex: 'ztgxkjbs'
          },
          {
            title:'适用范围',
            align:"center",
            dataIndex: 'ztgxuseranges'
          },
          {
            title:'使用限制',
            align:"center",
            dataIndex: 'ztgxuselimits'
          },
          {
            title:'推荐用量',
            align:"center",
            dataIndex: 'ztgxtjquantity'
          },
          {
            title:'竞品信息',
            align:"center",
            dataIndex: 'ztgxcompet'
          },
          {
            title: '操作',
            dataIndex: 'action',
            align:"center",
            fixed:"right",
            width:147,
            scopedSlots: { customRender: 'action' }
          }
        ],
        url: {
          list: "/roles/matrevbase/list",
          delete: "/roles/matrevbase/delete",
          deleteBatch: "/roles/matrevbase/deleteBatch",
          exportXlsUrl: "/roles/matrevbase/exportXls",
          importExcelUrl: "roles/matrevbase/importExcel",
          
        },
        dictOptions:{},
        superFieldList:[],
      }
    },
    created() {
    this.getSuperFieldList();
    },
    computed: {
      importExcelUrl: function(){
        return `${window._CONFIG['domianURL']}/${this.url.importExcelUrl}`;
      },
    },
    methods: {
      initDictConfig(){
      },
      getSuperFieldList(){
        let fieldList=[];
        fieldList.push({type:'string',value:'ztsendno',text:'报送码',dictCode:''})
        fieldList.push({type:'string',value:'ztcnname',text:'中文名称',dictCode:''})
        fieldList.push({type:'string',value:'ztenname',text:'INCI名称',dictCode:''})
        fieldList.push({type:'string',value:'ztstatus',text:'状态',dictCode:''})
        fieldList.push({type:'string',value:'ztprodcode',text:'生产代码',dictCode:''})
        fieldList.push({type:'string',value:'zttarget',text:'使用目的',dictCode:''})
        fieldList.push({type:'string',value:'ztequalmat',text:'等同原料',dictCode:''})
        fieldList.push({type:'string',value:'ztappearance',text:'外观性状',dictCode:''})
        fieldList.push({type:'string',value:'ztbrand',text:'生产商*',dictCode:''})
        fieldList.push({type:'string',value:'ztsupplier',text:'供应商',dictCode:''})
        fieldList.push({type:'string',value:'ztfactory',text:'所属工厂',dictCode:''})
        fieldList.push({type:'string',value:'ztorigin',text:'产地',dictCode:''})
        fieldList.push({type:'BigDecimal',value:'ztprice',text:'价格（元/kg)',dictCode:''})
        fieldList.push({type:'string',value:'ztcommon',text:'通用性',dictCode:''})
        fieldList.push({type:'string',value:'ztcommonrem',text:'备注（通用性）',dictCode:''})
        fieldList.push({type:'string',value:'ztpackmat',text:'包装材质',dictCode:''})
        fieldList.push({type:'BigDecimal',value:'ztpackmin',text:'最小包装（kg)',dictCode:''})
        fieldList.push({type:'BigDecimal',value:'ztordermin',text:'最小起订量（kg)',dictCode:''})
        fieldList.push({type:'string',value:'ztsupplycycle',text:'供货周期（天）',dictCode:''})
        fieldList.push({type:'string',value:'ztother',text:'其他',dictCode:''})
        fieldList.push({type:'string',value:'ztstability',text:'稳定性等级',dictCode:''})
        fieldList.push({type:'string',value:'ztsensible',text:'微生物敏感等级',dictCode:''})
        fieldList.push({type:'string',value:'ztquqntity',text:'保质期',dictCode:''})
        fieldList.push({type:'string',value:'ztstore',text:'储存条件',dictCode:''})
        fieldList.push({type:'string',value:'ztopenstore',text:'开封后储存条件',dictCode:''})
        fieldList.push({type:'string',value:'ztcaution',text:'注意事项',dictCode:''})
        fieldList.push({type:'string',value:'ztuserequire',text:'使用要求',dictCode:''})
        fieldList.push({type:'string',value:'ztviru',text:'急性毒性',dictCode:''})
        fieldList.push({type:'string',value:'ztcj',text:'刺激性/腐蚀性',dictCode:''})
        fieldList.push({type:'string',value:'ztzm',text:'致敏性',dictCode:''})
        fieldList.push({type:'string',value:'ztgt',text:'光毒性',dictCode:''})
        fieldList.push({type:'string',value:'ztgbt',text:'光变态反应',dictCode:''})
        fieldList.push({type:'string',value:'ztycdx',text:'致突变性/遗传毒性',dictCode:''})
        fieldList.push({type:'string',value:'ztcfjldx',text:'重复剂量毒性',dictCode:''})
        fieldList.push({type:'string',value:'ztszfytx',text:'生殖发育毒性',dictCode:''})
        fieldList.push({type:'string',value:'ztmxdx',text:'慢性毒性/致癌性',dictCode:''})
        fieldList.push({type:'string',value:'ztdddlx',text:'毒代动力学',dictCode:''})
        fieldList.push({type:'string',value:'ztrtsy',text:'人体试验',dictCode:''})
        fieldList.push({type:'string',value:'ztothers',text:'其他',dictCode:''})
        fieldList.push({type:'string',value:'ztgxuserange',text:'适用范围',dictCode:''})
        fieldList.push({type:'string',value:'ztgxuselimit',text:'使用限制',dictCode:''})
        fieldList.push({type:'string',value:'ztjsreyl',text:'推荐用量',dictCode:''})
        fieldList.push({type:'string',value:'ztxjmatclass',text:'原料类别',dictCode:''})
        fieldList.push({type:'string',value:'ztxjclass',text:'香精级别',dictCode:''})
        fieldList.push({type:'string',value:'ztxjsmell',text:'气味',dictCode:''})
        fieldList.push({type:'string',value:'ztxjprocess',text:'提取工艺',dictCode:''})
        fieldList.push({type:'string',value:'ztxjinspire',text:'灵感来源',dictCode:''})
        fieldList.push({type:'string',value:'ztxjscience',text:'香精科技',dictCode:''})
        fieldList.push({type:'string',value:'ztxjapptype',text:'应用类别',dictCode:''})
        fieldList.push({type:'string',value:'ztxjstable',text:'稳定性',dictCode:''})
        fieldList.push({type:'string',value:'ztxjcomponent',text:'天然成分（%）',dictCode:''})
        fieldList.push({type:'string',value:'ztxjmaincf',text:'主成分',dictCode:''})
        fieldList.push({type:'string',value:'ztxjdesc',text:'香气描述',dictCode:''})
        fieldList.push({type:'string',value:'ztxjzfzdesc',text:'消费者描述',dictCode:''})
        fieldList.push({type:'string',value:'ztxjsytype',text:'适用性别',dictCode:''})
        fieldList.push({type:'string',value:'ztxjgx',text:'功效',dictCode:''})
        fieldList.push({type:'string',value:'ztxjsjly',text:'数据来源',dictCode:''})
        fieldList.push({type:'string',value:'ztxjgxdata',text:'功效数据',dictCode:''})
        fieldList.push({type:'string',value:'ztxjqwrz',text:'权威认证',dictCode:''})
        fieldList.push({type:'string',value:'ztifra',text:'IFRA版本',dictCode:''})
        fieldList.push({type:'string',value:'ztgxeffect',text:'功效',dictCode:''})
        fieldList.push({type:'string',value:'ztgxdatasource',text:'数据来源',dictCode:''})
        fieldList.push({type:'string',value:'ztgxtestthick',text:'测试浓度',dictCode:''})
        fieldList.push({type:'string',value:'ztgxtestresult',text:'测试结果',dictCode:''})
        fieldList.push({type:'string',value:'ztgxother',text:'其他',dictCode:''})
        fieldList.push({type:'string',value:'ztgxbiological',text:'生物学靶点',dictCode:''})
        fieldList.push({type:'string',value:'ztgxkjbs',text:'科技背书',dictCode:''})
        fieldList.push({type:'string',value:'ztgxuseranges',text:'适用范围',dictCode:''})
        fieldList.push({type:'string',value:'ztgxuselimits',text:'使用限制',dictCode:''})
        fieldList.push({type:'string',value:'ztgxtjquantity',text:'推荐用量',dictCode:''})
        fieldList.push({type:'string',value:'ztgxcompet',text:'竞品信息',dictCode:''})
        this.superFieldList = fieldList
      }
    }
  }
</script>
<style scoped>
  @import '~@assets/less/common.less';
</style>